package com.xxx;



public class Account {
    private String id;
    private String password;
    private double money;



    public Account() {
    }

    public Account(String id, String password, double money) {
        this.id = id;
        this.password = password;
        this.money = money;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }
    //存钱
    public synchronized void depositMoney(double i) {
        try {
            if (money < 2000) {
                System.out.println("钱不够请存钱");
                this.money =this.money + i;
            }
            this.notifyAll();

            this.wait();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public synchronized void withdrawalOfMoney(double i) {
        try {
            if (money >= 2000) {
                System.out.println("钱到账了请取钱");
                this.money -= i;
            }
            this.notifyAll();

            this.wait();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

